//常规bfs通解

#include<bits/stdc++.h>
using namespace std;

const int maxn=20;
int vis[maxn][maxn];
int dx[]={1,1,2,2,-1,-1,-2,-2};
int dy[]={2,-2,1,-1,2,-2,1,-1};
struct point
{
    int x,y;
    int step;
}st,ed;

int r1,c1,r2,c2;


int bfs()
{
    queue<point>q;
    st.x=r1,st.y=c1,st.step=0;
    q.push(st);
    vis[st.x][st.y]=1;
    while(!q.empty())
    {
        st=q.front();q.pop();
        if(st.x==r2&&st.y==c2)return st.step;
        for(int i=0;i<8;i++)
        {
            ed.x=st.x+dx[i],ed.y=st.y+dy[i];ed.step=st.step+1;
            if(ed.x>=1&&ed.x<=8&&ed.y>=1&&ed.y<=8&&!vis[ed.x][ed.y])
            {
                vis[ed.x][ed.y]=1;
                q.push(ed);
            }
        }
    }
    return 0;
}

int main()
{
    string a,b;
    while(cin >> a >> b)
    {
        memset(vis,0,sizeof(vis));
        r1=a[0]-'a'+1,c1=a[1]-'0';
        r2=b[0]-'a'+1,c2=b[1]-'0';
        cout << "To get from " << a << " to " << b << " takes "  << bfs() << " knight moves." <<endl;
    }
    return 0;
}



//Astar（A*）解法

#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<math.h>
using namespace std;


int dx[]={1,1,2,2,-1,-1,-2,-2};
int dy[]={2,-2,1,-1,2,-2,1,-1};

const int maxn=20;
int vis[maxn][maxn];

struct point
{
    int g,h,f;
    int x,y,step;
    bool operator < (const point &a)const
    {
        /*if(g+h != a.g+a.h)return g+h>a.g+a.h;
        else return g>a.g;//退化成bfs*/
        return f>a.f;
    }
}st,ed;


inline int getD(int x,int y)//直线距离
{
    return (int)sqrt(x*x+y*y)*10+1;
}

inline int getH(point a,point b)//曼哈顿距离
{
    return (int)(abs(a.x-b.x)+abs(a.y-b.y))*10;
}

int r1,c1,r2,c2;

int Astar()
{
    priority_queue<point>q;
    memset(vis,0,sizeof(vis));
    st.step=st.g=st.h=st.f=0;
    st.x=r1,st.y=c1;
    q.push(st);
    vis[st.x][st.y]=1;

    while(!q.empty())
    {
        st=q.top(),q.pop();
        if(st.x==r2&&st.y==c2)return st.step;
        for(int i=0;i<8;i++)
        {
            ed.x=st.x+dx[i],ed.y=st.y+dy[i],ed.step=st.step+1;
            if(ed.x>=1&&ed.x<=8&&ed.y>=1&&ed.y<=8&&!vis[ed.x][ed.y])
            {
                ed.g=st.g+getD(dx[i],dy[i]);
                ed.h=getH(ed,st);
                ed.f=ed.g+ed.h;

                vis[ed.x][ed.y]=1;
                q.push(ed);
            }
        }
    }
}

int main()
{
    char a[5],b[5];
    while(scanf("%s%s",a,b)!=EOF)
    {
        r1=a[0]-'a'+1,c1=a[1]-'0';
        r2=b[0]-'a'+1,c2=b[1]-'0';
        printf("To get from %s to %s takes %d knight moves.\n",a,b,Astar());
    }
    return 0;
}
